package br.com.rodolfo.timesheet.dao;

import java.util.Date;
import java.util.List;

import javax.persistence.Query;

import br.com.rodolfo.timesheet.entity.Pausa;
import br.com.rodolfo.timesheet.entity.Pessoa;

public class PausaDAO extends GenericDAOImpl {
	
	@SuppressWarnings("unchecked")
	public List<Pausa> findPorDia(Pessoa p, Date dia)
			throws Exception{
		StringBuilder sQuery = new StringBuilder("from Pausa pb where ");
		sQuery.append("pb.ponto.pessoa = :pessoa and ");
		sQuery.append("pb.ponto.dia = :dia");
		
		Query q = entityManager.createQuery(sQuery.toString());
		q.setParameter("pessoa", p);
		q.setParameter("dia", dia);
		
		return (List<Pausa>)q.getResultList();
		
	}

}
